#bilibili排名算法 v90.0(2010.11.15)
#版本号9x.x是特殊榜单的专用版本号
#此版本专为『周刊哔哩哔哩排行榜SP』所用
class Results::R900 < Results::R20
  def get_ranking_point
    clicks_point = clicks * click_revised
    comment_point = comments * comment_revised
    ((clicks_point + comment_point + stows * 50) * space_fix ).to_i
  end

  def space_fix
    super * get_date_revised
  end

  #点击Part修正
  def self.get_click_revised parts, s=true
    f = format("%.2f", 2.0 / (parts + 1)).to_f
    f < 0.1 ? 0.1 : f
  end
  
  #评论修正
  def self.get_comment_revised fixed_clicks, comments
    if fixed_clicks >= comments.to_i * E_C
	  E_C
    else
      (E_C * fixed_clicks.to_f * 2 / (fixed_clicks.to_f + comments.to_f * E_C)).to_i
	end
  end
  
  #时间修正
  def get_date_revised
    Result.get_date_revised work.cdate
  end

  def self.get_date_revised date
    begin
      if date.to_datetime.compare_with_coercion('2010-01-24 00:00:00') == -1
        1.5
      elsif date.to_datetime.compare_with_coercion('2010-05-19 00:00:00') == -1
        1.4
      elsif date.to_datetime.compare_with_coercion('2010-09-22 00:00:00') == -1
        1.2
      else
        1.0
      end
    rescue
      1.0
    end
  end
end
